package com.rstar.readerbook;

import java.util.prefs.PreferenceChangeEvent;
import java.util.prefs.PreferenceChangeListener;

import android.app.Activity;
import android.app.ListFragment;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ReaderBookSetting extends  PreferenceActivity {
    private MyApplication application;
    private ListPreference fontSize;
    
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        addPreferencesFromResource(R.xml.preference);
        fontSize = (ListPreference) findPreference("fontsize_preference"); 
        fontSize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
			
			public boolean onPreferenceChange(Preference preference, Object newValue) {
				// TODO Auto-generated method stub
				fontSize.setSummary(newValue.toString());
				fontSize.setValue(newValue.toString());
				((MyApplication)getApplication()).setFontSize(Integer.valueOf(newValue.toString()));
				return false;
			}
		});
    }

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
        fontSize.setSummary(((MyApplication)getApplication()).getFontSize()+"");
        fontSize.setValue(((MyApplication)getApplication()).getFontSize()+"");
	} 
}

